#include <QtGui>
#include "src/Manager.h"
#include "src/Container/Attribute.h"
#include "src/Container/Question.h"
#include "src/Container/Result.h"
#include "src/Container/ResponseAttribute.h"
#include "TreeNode.h"

namespace XpsAssets
{
	class AssetReader
	{
		QXmlStreamReader xmlin;
		
	public:
		AssetReader(void);
		~AssetReader(void);

		Manager<Attribute> attributes;
		Manager<Question> questions;
		Manager<Result> results;
		Manager<Response> responses;

		QMap<int, TreeNode*> items;
		QList<unsigned int> linkQueue;

		void read(QString filename);

	private:
		void readXML();
		void readAssets();
		void readAttributesPool();
		void readQuestionsPool();
		void readResults();
		void readTreeNodes();
		void readConstraintNode(int id, int x, int y);
		void readQuestionNode(int id, int x, int y);
		void readNode(int id, int x, int y, TreeNode::NodeType type);
	};
}